<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
    
    $query=$mysqli->query("SELECT id FROM joinqiu where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $mysqli->query("delete from joinqiu where openid='".$openid."' ");
        $leaveLei=array('qiu'=>$openid);
    }
    
    $query=$mysqli->query("SELECT id,name FROM qdui where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $getQdui=$query->fetch_assoc();
        $getId=$getQdui['id'];
        $mysqli->query("delete from joinqiu where qiuid='".$getId."' ");
        $mysqli->query("delete from qdui where openid='".$openid."' ");
        $leaveLei=array('dui'=>$getId,'n'=>$getQdui['name']);
    }
    
    $mysqli->query("insert into leave_log(openid,lei,createtime) values('".$openid."','".json_encode($leaveLei, JSON_UNESCAPED_UNICODE)."','".date("Y-m-d H:i:s")."')  ");
    
    
    $mysqli->close();
    echo json_encode(array('s'=>'y'));
}

